package com.zzq.service.impl;

import com.zzq.annotation.EnableMyPage;
import com.zzq.domain.dto.SmilePointRuleDTO;
import com.zzq.domain.entity.SmilePointRule;
import com.zzq.domain.search.PointRuleSearchParamet;
import com.zzq.result.SmileResult;
import com.zzq.service.PointRuleAdminService;
import com.zzq.service.SmilePointRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class PointRuleAdminServiceImpl implements PointRuleAdminService {

    @Autowired
    SmilePointRuleService pointRuleService;
    @Override
    @Transactional
    public SmileResult add(SmilePointRule pointRule) {
        pointRuleService.save(pointRule);
        return SmileResult.sucess("成功");
    }
    @Override
    @Transactional
    public SmileResult upd(SmilePointRule pointRule){
        pointRuleService.updateById(pointRule);
        return SmileResult.sucess("成功");
    }

    @Override
    @EnableMyPage
    public SmileResult list(PointRuleSearchParamet searchParamet) {
        List<SmilePointRuleDTO> pointRuleList = pointRuleService.getPointRuleList(searchParamet);
        return SmileResult.sucess("成功",pointRuleList);
    }

    @Override
    @Transactional
    public SmileResult del(Long pointRuleId) {
        pointRuleService.removeById(pointRuleId);
        return SmileResult.sucess("成功");
    }
}
